/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Error.java
 *
 * Created on 19-abr-2011, 13:21:56
 */

package Comun;

import com.sun.awt.AWTUtilities;
import java.awt.Dimension;
import java.awt.Toolkit;

/**
 *
 * @author Luis
 */
public class Error extends javax.swing.JDialog {
   
        public int bot2=0;
        public String des="";
    /** Creates new form Error */
    public  Error(java.awt.Frame parent, boolean modal, String men, int bot, String cab) {
        super(parent, modal);
        setUndecorated(true);
        setResizable(false);
        AWTUtilities.setWindowOpaque(this, false);
        initComponents();
        bot2=bot;
       
        switch (bot){

                case 0:
                    this.samiButton2.setVisible(false);
                    this.jTextField1.setVisible(false);
                    this.pack();
                break;
            case 1:
                    this.jTextField1.setVisible(false);
                    this.samiButton1.setText("Si");
                    this.samiButton2.setText("No");
                    this.pack();

                
                break;
            case 2:
                
                break;

        }

       
        this.jLabel2.setText(men);
        this.jLabel3.setText(cab);


        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = this.getSize();
        if (frameSize.height > screenSize.height) {
            frameSize.height = screenSize.height;
        }
        if (frameSize.width > screenSize.width) {
            frameSize.width = screenSize.width;
        }
        this.setLocation((screenSize.width - frameSize.width+30)/2, (screenSize.height - frameSize.height-90)/2);
       
        //WindowsUtil.makeWindowsOpacity(this, .9f);

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        windowsUtil1 = new org.edisoncor.gui.util.WindowsUtil();
        panelRoundTranslucido1 = new Comun.PanelRoundTranslucido();
        jLabel3 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        samiButton1 = new Comun.SamiButton();
        samiButton2 = new Comun.SamiButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setUndecorated(true);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel3.setBackground(new java.awt.Color(255, 51, 51));
        jLabel3.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 18));
        jLabel3.setForeground(new java.awt.Color(0, 153, 204));
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("¡Atención!");

        jLabel2.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 14));
        jLabel2.setForeground(new java.awt.Color(255, 255, 255));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("Mensaje del Sistema");

        jTextField1.setFont(new java.awt.Font("Arial Rounded MT Bold", 0, 14));

        samiButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Iconos/SAMI_palomita 2.png"))); // NOI18N
        samiButton1.setText("Aceptar");
        samiButton1.setMouseEntered(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Iconos/SAMI_palomita.png"))); // NOI18N
        samiButton1.setMouseExited(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Iconos/SAMI_palomita 2.png"))); // NOI18N
        samiButton1.setMousePressed(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Iconos/SAMI_palomita.png"))); // NOI18N
        samiButton1.setMouseReleased(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Iconos/SAMI_palomita.png"))); // NOI18N
        samiButton1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                samiButton1MouseClicked(evt);
            }
        });

        samiButton2.setBackground(new java.awt.Color(0, 102, 255));
        samiButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Iconos/SAMI_dont 2.png"))); // NOI18N
        samiButton2.setText("Cancelar");
        samiButton2.setMouseEntered(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Iconos/SAMI_dont.png"))); // NOI18N
        samiButton2.setMouseExited(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Iconos/SAMI_dont 2.png"))); // NOI18N
        samiButton2.setMousePressed(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Iconos/SAMI_dont.png"))); // NOI18N
        samiButton2.setMouseReleased(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Iconos/SAMI_dont 2.png"))); // NOI18N
        samiButton2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                samiButton2MouseClicked(evt);
            }
        });

        org.jdesktop.layout.GroupLayout panelRoundTranslucido1Layout = new org.jdesktop.layout.GroupLayout(panelRoundTranslucido1);
        panelRoundTranslucido1.setLayout(panelRoundTranslucido1Layout);
        panelRoundTranslucido1Layout.setHorizontalGroup(
            panelRoundTranslucido1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelRoundTranslucido1Layout.createSequentialGroup()
                .addContainerGap()
                .add(panelRoundTranslucido1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(panelRoundTranslucido1Layout.createSequentialGroup()
                        .add(samiButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(18, 18, 18)
                        .add(samiButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(panelRoundTranslucido1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 318, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 318, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 318, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        panelRoundTranslucido1Layout.setVerticalGroup(
            panelRoundTranslucido1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(panelRoundTranslucido1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel3)
                .add(9, 9, 9)
                .add(jLabel2)
                .add(3, 3, 3)
                .add(jTextField1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(panelRoundTranslucido1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(samiButton2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(samiButton1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        getContentPane().add(panelRoundTranslucido1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 350, 160));

        pack();
    }// </editor-fold>//GEN-END:initComponents
public String activar(){
this.setVisible(true);

return(des);
}
    private void samiButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_samiButton1MouseClicked
        // TODO add your handling code here:
          switch (bot2){

                case 0:
                    this.dispose();
                break;
                case 1:
                    des="1";
                    this.dispose();

                break;
                
              case 2:
                  des=this.jTextField1.getText();
                  this.dispose();
                  break;
          }
    }//GEN-LAST:event_samiButton1MouseClicked

    private void samiButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_samiButton2MouseClicked
        this.dispose();
    }//GEN-LAST:event_samiButton2MouseClicked

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                Error dialog = new Error(new javax.swing.JFrame(), true,"",0,"");
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JTextField jTextField1;
    private Comun.PanelRoundTranslucido panelRoundTranslucido1;
    private Comun.SamiButton samiButton1;
    private Comun.SamiButton samiButton2;
    private org.edisoncor.gui.util.WindowsUtil windowsUtil1;
    // End of variables declaration//GEN-END:variables

   

}
